<?php

include './CsvToXml.php';
include './XmlToCsv.php';
if ($_POST != null) {
    $type = $_POST['type'];
    if ($type == 'xml') {
        move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "_file.xml");
        $xml = new DOMDocument();
        $xml->load("_file.xml");
        $converter = new XmlToCsv();
        $converter->convert($xml);
    } else if ($type == 'csv') {
        $input = fopen($_FILES["uploadedfile"]["tmp_name"], "r");
        $converter = new CsvToXml();
        $converter->convert($input);
    }
}